home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / etc / init.d / umountnfs.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  2006-10-06  |  1.8 KB  |  94 lines

  1. #! /bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:          umountnfs
  4. # Required-Start:    sendsigs
  5. # Required-Stop:
  6. # Default-Start:     6
  7. # Default-Stop:
  8. # Short-Description: Unmount all network filesystems except the root file system.
  9. # Description:       Also unmounts all virtual filesystems (proc, devfs, devpts,
  10. #                    usbfs, sysfs) that are not mounted at the top level.
  11. ### END INIT INFO
  12.  
  13. PATH=/usr/sbin:/usr/bin:/sbin:/bin
  14. KERNEL="$(uname -s)"
  15. RELEASE="$(uname -r)"
  16. . /lib/init/vars.sh
  17.  
  18. . /lib/lsb/init-functions
  19.  
  20. case "${KERNEL}:${RELEASE}" in
  21.   Linux:[01].*|Linux:2.[01].*)
  22.     FLAGS=""
  23.     ;;
  24.   Linux:2.[23].*|Linux:2.4.?|Linux:2.4.?-*|Linux:2.4.10|Linux:2.4.10-*)
  25.     FLAGS="-f"
  26.     ;;
  27.   *)
  28.     FLAGS="-f -l"
  29.     ;;
  30. esac
  31.  
  32. do_stop () {
  33.     # Write a reboot record to /var/log/wtmp before unmounting
  34.     halt -w
  35.  
  36.     # Remove bootclean flag files (precaution against symlink attacks)
  37.     rm -f /tmp/.clean /var/lock/.clean /var/run/.clean
  38.  
  39.     [ "$VERBOSE" = no ] || log_action_begin_msg "Unmounting remote and non-toplevel virtual filesystems"
  40.  
  41.     #
  42.     # Make list of points to unmount in reverse order of their creation
  43.     #
  44.  
  45.     exec 9<&0 </proc/mounts
  46.  
  47.     DIRS=""
  48.     while read DEV MTPT FSTYPE REST
  49.     do
  50.         case "$MTPT" in
  51.           /|/proc|/dev|/dev/pts|/dev/shm|/proc/*|/sys|/var/run|/var/lock)
  52.             continue
  53.             ;;
  54.         esac
  55.         case "$FSTYPE" in
  56.           nfs|nfs4|smbfs|ncp|ncpfs|cifs|coda|ocfs2|gfs)
  57.             DIRS="$MTPT $DIRS"
  58.             ;;
  59.           proc|procfs|linprocfs|devfs|devpts|usbfs|usbdevfs|sysfs)
  60.             DIRS="$MTPT $DIRS"
  61.             ;;
  62.         esac
  63.     done
  64.  
  65.     exec 0<&9 9<&-
  66.  
  67.     if [ "$DIRS" ]
  68.     then
  69.         umount $FLAGS $DIRS
  70.     fi
  71.     ES=$?
  72.  
  73.     [ "$VERBOSE" = no ] || log_action_end_msg $ES
  74. }
  75.  
  76. case "$1" in
  77.   start)
  78.     # No-op
  79.     ;;
  80.   restart|reload|force-reload)
  81.     echo "Error: argument '$1' not supported" >&2
  82.     exit 3
  83.     ;;
  84.   stop|"")
  85.     do_stop
  86.     ;;
  87.   *)
  88.     echo "Usage: umountnfs.sh [start|stop]" >&2
  89.     exit 3
  90.     ;;
  91. esac
  92.  
  93. :
  94.